Sample Code - DrillOnGroup Event

This sample code shows the use of the DrillOnGroup Event (Window Object). Modify the following sample code to fit your needs.

Dim rpt As CRPEAuto.Report
Dim rptView As CRPEAuto.View
Dim test As Integer

Private Sub DrillOnGroup_Click()
'Starts up report window for window event DrillOnGroup


On Error GoTo ErrorHandler
Set rpt = crsApp.OpenReport("c:\crw\reports\xtreme\www.sales.rpt")
rpt.PrintWindowOptions.CanDrillDown = True
rpt.PrintWindowOptions.HasGroupTree = True
test = MsgBox("Event default: Enabled = " & _
    rpt.EventInfo.GroupEventEnabled & Chr(13) & Chr(13) & _
    "Disable event?", vbYesNo)
If test = vbYes Then
rpt.EventInfo.GroupEventEnabled = False
MsgBox "Check event does not occur when drill on a group/graph/ grouptree"
Else
rpt.EventInfo.GroupEventEnabled = True
test = MsgBox("Check event occurs when drill on a _
        group/graph/grouptree" & Chr(13) & Chr(13) & _
        "Use default behaviour for test? ", vbYesNo)
If test = vbYes Then
def = True
Else
def = False
End If
End If
Set rptView = rpt.Preview
Set windowEvs = rptView.Parent
Exit Sub ' Exit to avoid handler.

ErrorHandler:
If crsApp.LastErrorCode <> 0 Then
MsgBox "Unexpected application error: " & crsApp.LastErrorCode & _
        "->" & crsApp.LastErrorString
End If
If rpt.LastErrorCode <> 0 Then
MsgBox "Unexpected application error: " & rpt.LastErrorCode & _
        "->" & rpt.LastErrorString
End If
If Err.Number <> 0 Then
MsgBox "Unexpected VB error: " & Err.Number & "->" & Err.Description
End If
Call ResetErr
rpt.ClearError
Resume Next
End Sub

Private Sub windowEvs_DrillOnGroup(ByVal GroupNameList As Variant, _
    ByVal DrillType As CRPEAuto.CRDrillType, useDefault As Boolean)
'executed when drill on group - test using default and _
'not using default behaviour
Dim x As Integer
For x = LBound(GroupNameList) To UBound(GroupNameList)
MsgBox "GroupName" & x & ": " & GroupNameList(x)
Next x
If def Then
'test for default behaviour:
MsgBox "Window DrillOnGroup event" & Chr(13) & Chr(13) & _
        "Parameters:" & Chr(13) & "GroupNameList: " & _
        GroupNameList(UBound(GroupNameList)) & Chr(13) & _
        "DrillType(on group=0;on grouptree=1;on graph=2): " & _
        DrillType & Chr(13) & "useDefault: " & useDefault & _
        Chr(13) & Chr(13) & "Drill down should occur"
Else
'test for no default behaviour:
useDefault = False
MsgBox "Window DrillOnGroup event" & Chr(13) & Chr(13) & _
        "Parameters:" & Chr(13) & "GroupNameList: " & _
        GroupNameList(UBound(GroupNameList)) & Chr(13) &
        "DrillType(on group=0;on grouptree=1;on graph=2): " & _
        DrillType & Chr(13) & "useDefault: " & useDefault & _
        Chr(13) & Chr(13) & "Drill down should NOT occur"
End If
End Sub


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com